<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/sm.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/base.css">
    <title>补卡审批</title>
    <style>
        .save-btn{height: 100%;line-height: 45px;}
        p{margin: 0;}
        .record-hd{ padding:5px;}
        .record-hd  span:last-child{  float: right;}
        .record-item{margin-bottom: 10px; height: 50px;line-height: 50px;background: #fff;border-bottom: 1px solid #dadada;padding: 0 10px;}
        .record-item >img{border-radius: 50%;vertical-align: middle;width: 35px;height: 35px;margin-right: 10px;margin-left: 5px;}
        .record-item .item-time{margin-right: 5px;}
        .item-big-input{height: auto;line-height: 2em;}
        .record-item input{height: 40px;border: none;}
        textarea{width: 100%;border: 1px solid #dadada;line-height: 1em;height: 80px;resize: none;}
        select{width: 100%;height: 100%;border:0;}
    </style>
</head>
<body>
<div class="page-group">
    <div class="page" data-url="${basepath}/front/offline/toOfflineResignApproveList" >
        <!--头部内容 !-->
        <header class="bar bar-nav">
            <a href="${basepath}/front/offline/toOfflineResignList" class="icon icon-left pull-left back" >返回</a>
            <h1 class="title">补卡审批 <span class="pull-right qrcode iconfont icon-erweima"></span></h1>
            <a href="javascript:;" class="pull-right save-btn">保存</a>
        </header>
        <div class="content">
            <div class="record-main">
                <div class="record-main my-sign-out-record">
                    <div class="record-item">
                        <span class="pull-left">补卡人</span>
                        <span class="pull-right sign-user">林志伟</span>
                    </div>
                    <div class="record-item item-big-input">
                        <span>补卡事由:</span>
                        <p><textarea  class="description" placeholder="请输入补卡事由"></textarea></p>
                    </div>
                    <div class="record-item">
                        <span class="pull-left">补卡类型</span>
                        <span class="pull-right sign-type">签到卡</span>
                    </div>
                    <div class="record-item" style="text-align: center;;">
                        <select>
                            <option value="审批类型">选择类型</option>
                            <option value="pass">通过</option>
                            <option value="fail">不通过</option>
                        </select>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>




<script type='text/javascript' src='${staticpath}/front/dist/js/lib/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='${staticpath}/front/dist/js/lib/sm.js' charset='utf-8'></script>
<script>
    function getQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    }
    //当前操作对象id
    var id = getQueryString("id");
    var approveType='';
    $('select').change(function(){
        approveType=$(this).val();
    })
//    查询 信息 填充
    $.ajax({
        url:'/front/retroactive/detail',
        type:'GET',
        dataType:'json',
        data:{
            id:id
        },
        success:function(res){
            if(res.success){
                var dataList=res.data;
                $('.sign-user').text(dataList.applicantName),
                $('.description').val(dataList.description);
                if(dataList.signType=='in'){
                    $('.sign-type').text('签到卡');
                }else{
                    $('.sign-type').text('签退卡');
                }
            }
        }
    })

    $('.save-btn').click(function(){
        if(approveType==''){
            $.toast('请选择审批类型')
        }else{
            $.ajax({
                url:'/front/retroactive/approval',
                type:'POST',
                dataType:'json',
                data:{
                    id:id,
                    status:approveType
                },
                success:function(res){
                    if(res.success){
                        $.toast('审批成功');
                        setTimeout(function(){
                        var url=$('.page').attr('data-url');
                            window.location.href=url;
                        },2000)
                    }
                }
            })
        }

    })




</script>
</body>
</html>